import {_TOTAL_PATH_} from '../../js/my-core'

// 获取热度排行榜
export const getHotList = (_this, val) => {
  const url = ['/api/anime/hot_list/10', '/api/manga/hot_list/10', '/api/novel/hot_list/10']
  _this.$axios({
    method: 'get',
    url: url[val]
  })
    .then((res) => {
      if (res.data.code === 200) {
        _this.rankingList = []
        let i = 0
        for (let item of res.data.data) {
          let rank = {id: i, name: 'NULL', href: '#'}
          rank.name = item.name
          rank.href = _TOTAL_PATH_[val] + item.id
          _this.rankingList.push(rank)
          i++
        }
      } else {
        console.log(res.data.msg)
      }
    })
    .catch((error) => {
      console.log(error)
    })
}

export const getCountList = (_this, val) => {
  const url = ['/api/anime/count_list/24', '/api/manga/count_list/24', '/api/novel/count_list/24']
  _this.$axios({
    method: 'get',
    url: url[val]
  })
    .then((res) => {
      if (res.data.code === 200) {
        // console.log(res.data.data[0])
        _this.videoList = []
        let i = 0
        for (let item of res.data.data) {
          const video = {id: i, data: {count: 2000, cover: '', href: '#', name: 'NULL', tag: 2, status: 0, allNum: 0, refreshNum: 0}}
          video.data.name = item.name
          video.data.cover = item.cover
          video.data.count = item.count
          video.data.href = _TOTAL_PATH_[val] + item.id
          video.data.tag = item.tag
          video.data.status = item.status
          video.data.allNum = item.allNum
          video.data.refreshNum = item.refreshNum
          _this.videoList.push(video)
          i++
        }
        _this.videos = _this.videoList.slice(0, 8)
      } else {
        console.log(res.data.msg)
      }
    })
    .catch((error) => {
      console.log(error)
    })
}
